/**
 * 
 */
package TestCases;

import Tracer.RTCanvas;
import Tracer.RTVector;
import junit.framework.TestCase;

/**
 * @author
 * 
 */
public class RTCanvasTest extends TestCase {

	/**
	 * The RTCanvas instance for test
	 */
	private RTCanvas canvas;
	private RTCanvas canvas2;

	/**
	 * @param name
	 *            The Constructor of RTCanvasTest
	 */
	public RTCanvasTest(String name) {
		super(name);
	}

	/**
	 * The setUp for Test Case, to initialize data
	 */
	protected void setUp() throws Exception {
		super.setUp();
		canvas = new RTCanvas();
		canvas2 = new RTCanvas();
		canvas2.setCornerUL(new RTVector(1.1, 1.3, 15));
		canvas2.setDownD(new RTVector(0, 5, 3));
		canvas2.setRightD(new RTVector(7, 0, 0));
		canvas2.setHeight(15);
		canvas2.setWidth(20);
		canvas2.setYpix(3);
		canvas2.setXpix(4);
		canvas2.setZoom(2);
		canvas2.setIsShadowingReflection(true);
		canvas2.setReflectionDepth(10);
	}

	/**
	 * The tearDown for Test Case, to release the data
	 */
	protected void tearDown() throws Exception {
		super.tearDown();
	}

	/**
	 * Test for Get_cornerUL Function Will be equal to the expected result if
	 * pass
	 */
	public void testGet_cornerUL() {
		RTVector testVector = new RTVector(1.1d, 1.3d, 15d);
		assertTrue(canvas2.getCornerUL().isEqual(testVector));
	}

	/**
	 * Test for Set_cornerUL Function Will be equal to the expected result if
	 * pass
	 */
	public void testSet_cornerUL() {
		RTVector cornerUL = new RTVector(12d, 5d, 10d);
		canvas.setCornerUL(cornerUL);
		RTVector testVector = new RTVector(24d, 10d, 20d);
		assertTrue(testVector.isEqual(RTVector.multipleVectors(canvas
				.getCornerUL(), 2)));
	}

	/**
	 * Test for Get_rightD Function Will be equal to the expected result if pass
	 */
	public void testGet_rightD() {
		RTVector testVector = new RTVector(7d, 0d, 0d);
		assertTrue(canvas2.getRightD().isEqual(testVector));
	}

	/**
	 * Test for Set_rightD Function Will be equal to the expected result if pass
	 */
	public void testSet_rightD() {
		RTVector rightVec = new RTVector(12d, 5d, 10d);
		canvas.setRightD(rightVec);
		RTVector testVector = new RTVector(24d, 10d, 20d);
		assertTrue(testVector.isEqual(RTVector.multipleVectors(canvas
				.getRightD(), 2)));
	}

	/**
	 * Test for Get_downD Function Will be equal to the expected result if pass
	 */
	public void testGet_downD() {
		RTVector testVector = new RTVector(0d, 5d, 3d);
		assertTrue(canvas2.getDownD().isEqual(testVector));
	}

	/**
	 * Test for Set_downD Function Will be equal to the expected result if pass
	 */
	public void testSet_downD() {
		RTVector downVec = new RTVector(0, -1, 0);
		canvas.setDownD(downVec);
		RTVector testVector = new RTVector(0d, -2d, 0d);
		assertTrue(testVector.isEqual(RTVector.multipleVectors(canvas
				.getDownD(), 2)));
	}

	/**
	 * Test for Get_width Function Will be equal to the expected result if pass
	 */
	public void testGet_width() {
		assertEquals(20d, canvas2.getWidth());
	}

	/**
	 * Test for Set_width Function Will be equal to the expected result if pass
	 */
	public void testSet_width() {
		canvas.setWidth(18);
		assertEquals(18d, canvas.getWidth());
		canvas.setWidth(-1);
		assertEquals(2d, canvas.getWidth());
		canvas.setWidth(0);
		assertEquals(2d, canvas.getWidth());
	}

	/**
	 * Test for Get_height Function Will be equal to the expected result if pass
	 */
	public void testGet_height() {
		assertEquals(15d, canvas2.getHeight());
	}

	/**
	 * Test for Set_height Function Will be equal to the expected result if pass
	 */
	public void testSet_height() {
		canvas.setHeight(24);
		assertEquals(24d, canvas.getHeight());
		canvas.setHeight(-24);
		assertEquals(2d, canvas.getHeight());
		canvas.setHeight(0);
		assertEquals(2d, canvas.getHeight());
	}

	/**
	 * Test for Get_zoom Function Will be equal to the expected result if pass
	 */
	public void testGet_zoom() {
		assertEquals(2d, canvas2.getZoom());
	}

	/**
	 * Test for Set_zoom Function Will be equal to the expected result if pass
	 */
	public void testSet_zoom() {
		canvas.setZoom(4.5);
		assertEquals(4.5d, canvas.getZoom());
	}

	/**
	 * Test for Get_xpix Function Will be equal to the expected result if pass
	 */
	public void testGet_xpix() {
		assertEquals(4, canvas2.getXpix());
	}

	/**
	 * Test for Set_xpix Function Will be equal to the expected result if pass
	 */
	public void testSet_xpix() {
		canvas.setXpix(3);
		assertEquals(3, canvas.getXpix());
		canvas.setXpix(-3);
		assertEquals(240, canvas.getXpix());
		canvas.setXpix(0);
		assertEquals(240, canvas.getXpix());
	}

	/**
	 * Test for Get_ypix Function Will be equal to the expected result if pass
	 */
	public void testGet_ypix() {
		assertEquals(3, canvas2.getYpix());
	}

	/**
	 * Test for Set_ypix Function Will be equal to the expected result if pass
	 */
	public void testSet_ypix() {
		canvas.setXpix(4);
		assertEquals(4, canvas.getXpix());
		canvas.setXpix(-4);
		assertEquals(240, canvas.getXpix());
		canvas.setXpix(0);
		assertEquals(240, canvas.getXpix());
	}

	/**
	 * Test for Get_Rx Function Will be equal to the expected result if pass
	 */
	public void testGet_Rx() {
		assertEquals(5d, canvas2.getRx());
	}

	/**
	 * Test for Get_Ry Function Will be equal to the expected result if pass
	 */
	public void testGet_Ry() {
		assertEquals(5d, canvas2.getRy());
	}

	/**
	 * Test for GetReflectionDepth Function Will be equal to the expected result
	 * if pass
	 */
	public void testGetReflectionDepth() {
		assertEquals(10, canvas2.getReflectionDepth());
	}

	/**
	 * Test for SetReflectionDepth Function Will be equal to the expected result
	 * if pass
	 */
	public void testSetReflectionDepth() {
		canvas.setReflectionDepth(12);
		assertEquals(12, canvas.getReflectionDepth());
		canvas.setReflectionDepth(-12);
		assertEquals(1, canvas.getReflectionDepth());
		canvas.setReflectionDepth(0);
		assertEquals(1, canvas.getReflectionDepth());
	}

	/**
	 * Test for GetIsShadowingReflection Function Will be equal to the expected
	 * result if pass
	 */
	public void testGetIsShadowingReflection() {
		assertTrue(canvas2.getIsShadowingReflection());
	}

	/**
	 * Test for SetIsShadowingReflection Function Will be equal to the expected
	 * result if pass
	 */
	public void testSetIsShadowingReflection() {
		canvas.setIsShadowingReflection(false);
		assertFalse(canvas.getIsShadowingReflection());
		canvas.setIsShadowingReflection(true);
		assertTrue(canvas.getIsShadowingReflection());
	}
}
